<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui-v2.6.8/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
</head>
<body>
<button class="layui-btn layui-btn-radius layui-btn-lg layui-btn-danger" id="id_btn">清理缓存</button>
<script src="/lib/layui-v2.6.8/layui.js" charset="utf-8"></script>
<script src="/js/lay-config.js?v=2.0.0" charset="utf-8"></script>
<script>
    layui.use(['layer'], function () {
        var $ = layui.jquery,
            layer = layui.layer;

        $.get('/admin/user/getCurrent', {}, function (re) {
            if (re.code == 0) {
                layui.use('watermark', function (watermark) {
                    watermark({watermark_txt: re.data.name});
                });
            }
        }, 'json');

        $('#id_btn').click(function () {
            layer.confirm('确定要清理缓存吗 ?', function (index) {
                layer.close(index);
                let loading = layer.load(2);
                $.post('/admin/clear_cache/clear', {}, function (re) {
                    if (re.code == 0) {
                        layer.msg('清理成功 !');
                    } else {
                        layer.msg('清理失败 ! ' + re.msg());
                    }
                    layer.close(loading);
                }, 'json');
            });
        });

    });
</script>
</body>
</html>